Ext.define('MyBlog.store.EntryList', {
	extend: 'Ext.data.TreeStore',
	
	model: 'MyBlog.model.Entry',
	
	id: 'entryListStore',
	
	autoLoad: true,
	
	proxy: {
		type: 'ajax',

		url: 'data/entries.php'
		/*api: {
			//read: 'data/users.json',
			update: 'data/users.json'
		},
		reader: {
			type: 'json',
			root: 'users',
			successProperty: 'success'
		}*/
	},
	listeners: {
        
        // Each demo.UserModel instance will be automatically 
        // decorated with methods/properties of Ext.data.NodeInterface 
        // (i.e., a "node"). Whenever a UserModel node is appended
        // to the tree, this TreeStore will fire an "append" event.
        append: function( thisNode, newChildNode, index, eOpts ) {
            
            // If the node that's being appended isn't a root node, then we can 
            // assume it's one of our UserModel instances that's been "dressed 
            // up" as a node
            if( !newChildNode.isRoot() ) {
                
                // The node is a UserModel instance with NodeInterface
                // properties and methods added. We want to customize those 
                // node properties  to control how it appears in the TreePanel.
                
                // A user "item" shouldn't be expandable in the tree
                newChildNode.set('leaf', true);
                
                // Use the model's "name" value as the text for each tree item
                newChildNode.set('text', newChildNode.get('title'));
				
				newChildNode.set('id', newChildNode.get('id'));

            }
        }
	}
	
    /*root: {
        expanded: true,
        children: [
            { text: "title 1", leaf: true },
            { text: "title 2", leaf: true },
			{ text: "title 3", leaf: true }
        ]
    }*/
});